package slap.concurrent;

import java.util.concurrent.Future;

import slap.exception.SlapException;

public class Suspend extends SlapException {

	/**
	 * Suspend for a timeout (in milliseconds).Suspend
	 */
	long timeout;

	/**
	 * Wait for task execution.
	 */
	Future<?> task;

	public Suspend(long timeout) {
		this.timeout = timeout;
	}

	public Suspend(Future<?> task) {
		this.task = task;
	}

	@Override
	public String getErrorTitle() {
		return "Request is suspended";
	}

	@Override
	public String getErrorDescription() {
		if (task != null) {
			return "Wait for " + task;
		}
		return "Retry in " + timeout + " ms.";
	}
}